 $('.select2').select2()
	  $('#reservation').daterangepicker({
	  	locale:{format:'YYYY-MM-DD'}
	  });
	  	$('#reservation').val('请选择时间')
	  	
		 function getData1(curr){
	 	          var data_rang = $('.data_pick').val();//时间范围
				  var evKind = $('.event_kind').select2('val');
				  var start = data_rang.split(' -')[0];
				  var end = data_rang.split('- ')[1];
				  var timeOnoff = "False";
				  if(data_rang!=''&&data_rang!='请选择时间'){
				  	timeOnoff = "True"
				  }
				  $.ajax({
				  	type:"get",
				  	url:"https://www.retux.cn/MgProductApprove",
				  	async:true,
				  	data:{
				  		page:curr ,
				  		row: 10,
				  		Kind:evKind,
				  		end:end ,
				  		start:start ,
				  		Time:timeOnoff,
				  		Content:$('.search_text').val()
				  	},
				  	success:function(data){
				  		if(data[0].length==0){
				  			layer.msg('暂无数据')
				  		}
				  		TableView(data[0]);
				  		pageDivd(curr,data[1]);
				  		$('.all_data').html(data[1])
				  	}
				  });
			}
		 $('.search_btn1').click(function(){
		 	getData1(1);
		 })
		    getData1(1);
	 	    function pageDivd(curr,page_num){
	 	    	layui.use(['laypage', 'layer'], function(){
				  var laypage = layui.laypage
				  ,layer = layui.layer;
				    laypage.render({
				    elem: 'demo7'
				    ,count: page_num
				    ,limit:10
				    ,curr:curr
				    ,jump: function(obj,first){
				    	if(!first){
				    			getData1(obj.curr);
				    		
				    	}
				    }
				  });
				})
	 	    }
	 	     function TableView(data){
	 	    	$('.table_data').html('');
	 	    	for (var i=0;i<data.length;i++) {
	 	    		if(data[i][6]=='修改'){
	 	    		     var labelText = `<label class="label1 status" value="Modify">${data[i][6]}</label>`;
	 	    		}else if(data[i][6]=='新增'){
	 	    			 var labelText = `<label class="label2 status" value="Increase">${data[i][6]}</label>`;
	 	    		}else{
	 	    		 	 var labelText = `<label class="label3 status" value="Create">${data[i][6]}</label>`;	
	 	    		}
	 	    		var trText = `
	 	    				<tr>
		      		    		<td><input eventid="${data[i][7]}" type="checkbox"/></input></td>
		      		    		<td>${data[i][0]}</td>
		      		    		<td>${data[i][1]}</td>
		      		    		<td>
		      		    			<img src="${data[i][2]}" height="50"/>
		      		    		</td>
		      		    		<td>
		      		    			${data[i][3]}
		      		    		</td>
		      		    		<td>
		      		    			${data[i][4]}
		      		    		</td>
		      		    		<td>
		      		    			${data[i][5]}
		      		    		</td>
		      		    		<td>
		      		    				${labelText}
		      		    		</td>
		      		    		<td index="${data[i][0]}" eventid="${data[i][7]}">
		      		    			<div class="btn_done">
		      		    				<a class="look_detail" href="#">查看</a>
		      		    				<a class="check_btn" kind="1" href="#">审核</a>
		      		    				<a class="check_btn" kind="2" href="#">删除</a>
		      		    			</div>
		      		    		</td>
		      		    	</tr>
		      		    	`;
		      		    	
		      		 $('.table_data').append(trText) ;  	
		      		    	
	 	    	}
	 	    	table_operate();
	 	    }
	 	    function table_operate(){
	 	    	//商品全选
	 	    	$("#check_all").click(function(){
		 	    	if($(this).prop('checked')==true){
		 	    		
		 	    		$("tbody").find('input[type=checkbox]').prop('checked','checked')
		 	    	}else{
		 	    		$("tbody").find('input[type=checkbox]').prop('checked',false)
		 	    	}
		 	    })
	 	    	$('.look_detail').click(function(){
	 	    		var eventId = $(this).parent().parent().attr('eventid');//事件Id
	 	    		var proStatus = $(this).parents('tr').find('.status').attr('value');//状态
	 	    		
	 	    		var Index = $(this).parent().parent().attr('index');//商品id
	 	    		
	 	    		window.location.href='http://119.23.212.200:30000/confirm_check.html?Index='+Index+'&eventId='+eventId+'&status='+proStatus;
	 	    	})
	 	    	$('.check_btn').click(function(){
	 	    		var eventid = $(this).parent().parent().attr('eventid');
	 	    		var Kind = $(this).attr('kind');
	 	    		var checkNode = $("tbody").find('input[type=checkbox]:checked');
	 	    		var checkArr=[];
	 	    		
	 	    		if(checkNode.length>0){
		 	    		for (var i = 0;i<checkNode.length;i++) {
		 	    			var eventId = checkNode.eq(i).attr('eventid');
		 	    			checkArr.push(eventId);
		 	    		}
	 	    		}else{
	 	    			checkArr.push(eventid);
	 	    		}
	 	    		$.ajax({
	 	    			type:"get",
	 	    			url:"https://www.retux.cn/MgProductApproveSubmit",
	 	    			async:true,
	 	    			data:{
	 	    				Id:checkArr.join('-'),
	 	    				Kind:Kind
	 	    			},
	 	    			success:function(data){
	 	    				if(data=='success'){
	 	    					 if(Kind==1){
	 	    					 	layer.msg('审批成功',{time:500},function(){
			 	    					location.reload();
			 	    					})
	 	    					 }else{
	 	    					 	layer.msg('删除成功',{time:500},function(){
			 	    					location.reload();
			 	    					})
	 	    					 }
	 	    					
	 	    				}else{
	 	    					layer.msg('审批失败',{time:500})
	 	    				}
	 	    			}
	 	    		});
	 	    		
	 	    	})
	 	    }